#ifndef SERVER_MANAGE_H
#define SERVER_MANAGE_H

#include <wx/event.h>
#include <thread>
#include <exception>
#include <string>
#ifdef _MSC_VER
#define fmt std
#include <format>
#else
#include <fmt/format.h>
#endif
#include "ServerCore.h"
#include "ImageDisplay.h"
#include "ServerHandle.h"

enum class DeviceStatus : int32_t
{
    deviceError=0x0,
    UnInit=0x1,
    connectCamera=0x2,
    openCamera=0x3,
    startShot=0x4,
    startCollege=0x5
};

class ServerManageException : public std::exception
{
    public:
        ServerManageException(std::string _str) : str(_str)
        {}
        virtual const char* what()
        {return str.c_str();}
    private:
        std::string str;
};

class ServerManage
{
public:
    ServerManage(wxEvtHandler* evtHandler,int id);
    void SetDevice(long devID);
    void InitDevice();
    void ControlShot();
    void ControlCollege();
    DeviceStatus GetDeviceInfo();
    CameraParament GetCameraPara();
    void SetExposeTime(int32_t value);
    void SetImageHeight(const int32_t value);
    void SetImageWidth(const int32_t value);
    void SetImageOffsetX(const int32_t value);
    void SetImageOffsetY(const int32_t value);
    void SetFrameRate(const int32_t value);
    void SetTriggerMode(bool mode);
    bool FileTransferFunc(const std::string& savePath);
    virtual ~ServerManage();
private:
    ServerHandle serverHandle;
    std::thread networkThread;
    ServerCore serverCore;
    long CurrentDeviceID=-1;
    bool allControl;
};

#endif
